<?php
include_once('config.php');
include_once('model/users.php');

$username = $_POST['username'];
$password = $_POST['password'];

if(authorize($username, $password) == true){

	// create the session. After this, $_SESSION will be available to our files
	Session::start($username);
	header("Location: wall.php");
}
else{
	//render login
	$index_view = new Template('login_view.php');
	$index_view->render();	
}

function authorize($username, $password){
	$user = new Users();
	return $user->authorize($username, $password);
}